﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Web.Configuration;
using DTO;
using System.Data;

namespace DAL
{
    public abstract class AbstractDal
    {
        protected MySqlConnection conn;

        public AbstractDal()
        {
            string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            conn = new MySqlConnection(connStr);
        }

        protected void AbrirConexao()
        {
            try
            {
                if(conn.State == System.Data.ConnectionState.Closed)
                    conn.Open();
            }
            catch
            {
                throw;
            }
        }
        protected void FecharConexao()
        {


            try
            {
                if (conn.State == System.Data.ConnectionState.Open)
                    conn.Close();
            }
            catch
            {
                throw;
            }
        }
    }
}
